package com.aqielife.demo.example.lambda;

public class ThreadDemo {
    public static void main(String[] args) {
        Object object = new Runnable() {
            @Override
            public void run() {
                System.out.println('a');
            }
        };
        new Thread((Runnable) object).start();

        // lambda
        new Thread(() -> System.out.println("oj8k")).start();            // 最简洁

        Object target = (Runnable)() -> System.out.println("ok");
        Runnable target2 = () -> System.out.println("ok");              // 返回实现Runnable对象接口的实例
        System.out.println(object == target);                           // 两个对象 false
        // System.out.println(target2 == target);                      // λ返回是两个对象 false
        new Thread((Runnable) target).start();
    }

}
